package com.fuint.application.dao.repositories;

import com.fuint.base.dao.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.fuint.application.dao.entities.MtUserAction;
import java.util.Date;

/**
* mt_user_action Repository
* Created by FSQ
* Contact wx fsq_better
* Site https://www.fuint.cn
*/ 
@Repository 
public interface MtUserActionRepository extends BaseRepository<MtUserAction, Integer> {

    /**
     * 获取活跃会员总数
     *
     * @return
     */
    @Query("SELECT count(DISTINCT t.userId) as num FROM MtUserAction t where t.status='A' and t.updateTime <= :endTime and t.updateTime >= :beginTime")
    Long getActiveUserCount(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime);

    /**
     * 获取活跃会员总数
     *
     * @return
     */
    @Query("SELECT count(DISTINCT t.userId) as num FROM MtUserAction t where t.storeId = :storeId and t.status='A' and t.updateTime <= :endTime and t.updateTime >= :beginTime")
    Long getActiveUserCount(@Param("storeId") Integer storeId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
}

